<?php

namespace App\Repositories\Remotes;

use Closure;
use GuzzleHttp\Exception\RequestException;

class Middleware
{
    /**
     * @param  \Illuminate\Http\Request $request
     * @param  \Closure                 $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        try {
            return $next($request);
        } catch (RequestException $e) {
            return response()->json(['error' => 'network']);
        }
    }
}
